package commonwebgroup.commonwebartifact.Models;

import java.util.Objects;
import java.util.StringJoiner;

/**
 * @author: wuxin0011
 * @Description:
 */
public class ApiResModel {
    private int status;
    private String message;
    private boolean success;
    private Object response;

    public ApiResModel(int status, String message, boolean success, Object response) {
        this.status = status;
        this.message = message;
        this.success = success;
        this.response = response;
    }

    public int getStatus() {
        return status;
    }

    public void setStatus(int status) {
        this.status = status;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public boolean isSuccess() {
        return success;
    }

    public void setSuccess(boolean success) {
        this.success = success;
    }

    public Object getResponse() {
        return response;
    }

    public void setResponse(Object response) {
        this.response = response;
    }

    @Override
    public String toString() {
        return new StringJoiner(", ", ApiResModel.class.getSimpleName() + "[", "]")
                .add("status=" + status)
                .add("message='" + message + "'")
                .add("success=" + success)
                .add("response=" + response)
                .toString();
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        ApiResModel that = (ApiResModel) o;

        if (status != that.status) return false;
        if (success != that.success) return false;
        if (!Objects.equals(message, that.message)) return false;
        return Objects.equals(response, that.response);
    }

    @Override
    public int hashCode() {
        int result = status;
        result = 31 * result + (message != null ? message.hashCode() : 0);
        result = 31 * result + (success ? 1 : 0);
        result = 31 * result + (response != null ? response.hashCode() : 0);
        return result;
    }
}
